package cn.wolfcode.qo;



import lombok.Getter;
import lombok.Setter;

import java.util.List;
@Setter
@Getter
public class PageResult<T> {
    private int currentPage;
    private int pageSize;
    private List<T> data;
    private int totalCount;

    private int totalPage;
    private int prevPage;
    private int nextPage;

    public PageResult(int currentPage, int pageSize, List<T> data, int totalCount) {
        this.currentPage = currentPage;
        this.pageSize = pageSize;
        this.data = data;
        this.totalCount = totalCount;

        this.totalPage=totalCount%pageSize == 0 ? totalCount/pageSize : totalCount/pageSize +1;
        this.prevPage=currentPage-1 >= 1 ? currentPage-1 : 1;
        this.nextPage=currentPage+1 <=totalPage? currentPage+1:totalPage;
    }
}
